<!-- 地址管理页面的卡片内容组件 -->
<template>
  <div class="address-card" @click="handleEdit(address._id)">
    <div class="address-card-info">
      <div class="info-title">
        <div class="info-title-name">{{address.name}}</div>
        <div class="info-title-number">{{ address.phone }}</div>
      </div>
      <div class="info-content">{{address.city}}市 {{ address.department }} {{ address.houseNumber }}</div>
    </div>
    <div class="address-card-to">
      <i class="iconfont">&#xe604;</i>
    </div>
  </div>
</template>

<script>
import { useRouter } from 'vue-router';
// 处理点击跳转
const useClick = (router) => {
  const handleEdit = (id) => {
    // 处理跳转逻辑，如果从编辑页回到管理页，点击管理页返回按钮应该回到 我的 页面
    localStorage.forEdit = true;
    router.push({name:'editAddress',params:{id}})
  }
  return {handleEdit}
}
//composition
export default {
  name:'addreddCard',
  props:['address'],
  setup(){
    const router = useRouter();
    const {handleEdit} = useClick(router);
    return {handleEdit}
  }
}
</script>

<style scoped lang="scss">
@import '@/styles/theme.scss';
@import '@/styles/mixin.scss';
.address-card{
  height: 28vw;
  background-color: $white;
  padding: 18px 16px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4.2667vw;
  &-info{
    flex: auto;
    width: 65.3333vw;
    padding-right: 10.6667vw;
    font-size: 14px;
    .info-title{
      color: #999999;
      display: flex;
      margin-bottom: 10px;
      &-name{
        width: 38%;
      }
    }
    .info-content{
      color: $theme-font-color;
      line-height: 1.5;
      @include multi-line-ellipsis;
    }
  }
  &-to{
    transform: rotate(180deg);
    .iconfont{
      font-size: 20px;
      color: #999;
    }
  }
}
</style>